import { DataTypes } from "sequelize";
import sequelize from "./db";
import { UserType } from "../entities/constraints";

export default sequelize.define('users', {
  "class_id": {
    type: DataTypes.UUID,
    primaryKey: true,
    allowNull: true,
    defaultValue: DataTypes.UUIDV4
  },

  'id': {
    type: DataTypes.UUID,
    allowNull: false,
    unique: true,
    defaultValue: DataTypes.UUIDV4
  },

  'nickname': {
    type: DataTypes.STRING(10),
    allowNull: false,
  },

  'account': {
    type: DataTypes.STRING(40),
    allowNull: false,
    unique: true,
  },

  'password': {
    type: DataTypes.STRING(40),
    allowNull: true,
  },

  'type': {
    type: DataTypes.INTEGER,
    allowNull: false,
    defaultValue: UserType.student
  }
}, {
  createdAt: false,
  updatedAt: false,
  freezeTableName: true
})